#ifndef _APPS_BWM_CBARDECORATION_H_
#define _APPS_BWM_CBARDECORATION_H_

#include "cmanageddecoration.h"
#include <buola/image/ctextlayout.h>

namespace buola { namespace bwm {

class CBarButton
{
public:
    CBarButton(CManagedDecoration::EButton pID)
    {
        mID=pID;
        mEnabled=true;
    }

    CManagedDecoration::EButton mID;
    CRect_d mRect;
    bool mEnabled;
};

class CBarDecoration : public CManagedDecoration
{
public:
    CBarDecoration(CManagedClient *pClient);
    virtual ~CBarDecoration();

    virtual void InitInternal();
    virtual void InitStatic();

    virtual CRect_i GetTotalExtent();
    virtual CRect_i GetFrameExtent();

    virtual void CreatePixmap();

    void PlaceText();
    void PlaceButtons(const CSize_d&);

//Event management
    virtual void OnLabelChanged();
    virtual void OnGeometryChanged(bool pResize,const CPoint_i &pPos,
                            const CSize_i &pSize,const CPoint_i &pXPos);
    virtual void OnButtonDown(const CPoint_d&,gui::EMouseButton,int);
    virtual void OnButtonUp(const CPoint_d&,gui::EMouseButton,int);
    virtual void OnMouseMove(const CPoint_d&);
    virtual void OnMouseOut();

protected:
/////////////////// helpers /////////////////
    virtual gui::EDragState GetDraggingZone(const CPoint_d&);

protected:
    CManagedClient *mManagedClient;
    int mL,mT,mR,mB;
    int mDL,mDT,mDR,mDB;
    int mSL,mST,mSR,mSB;

    img::CTextLayout mTitleLayout;
    int mTitleX;
    int mTitleWidth;

    std::vector<std::unique_ptr<CBarButton>> mButtons;
    CBarButton *mInside;
    CBarButton *mPressed;

    static img::CColor mInactiveColor;
//    static gui::x11::CPixmap *mShadow,*mBlackPicture;
//    static CSize_d mShadowSize;
    static bool mImageInit;
};

/*namespace bwm*/ } /*namespace buola*/ }

#endif
